package clientMain;
// <editor-fold defaultstate="collapsed" desc="Imports">

import lib.StreamSocket;
import java.util.Scanner;
import java.util.logging.Level;
import java.util.logging.Logger;
// </editor-fold>

/**
 * @file Transmitter.java
 *
 * @version 0.1
 * @author Chris Sewell 10008342
 */
public class Transmitter extends Thread {
    // <editor-fold defaultstate="collapsed" desc="Attributes">

    StreamSocket serverStream;
    Scanner scan;
    String serverInput;
    // </editor-fold>
    // <editor-fold defaultstate="collapsed" desc="Constructors">

    public Transmitter(StreamSocket serverStream) {
        this.serverStream = serverStream;
        scan = new Scanner(System.in);
    }
    // </editor-fold>
    // <editor-fold defaultstate="collapsed" desc="Methods">

    @Override
    public void run() {
        while (serverStream.isOpen()) {
            //Receive string from keyboard input
            serverInput = scan.nextLine();
            //Send string to server
            serverStream.sendString(serverInput);
            try {
                Thread.sleep(50);
            } catch (InterruptedException ex) {
                Logger.getLogger(Transmitter.class.getName()).log(Level.SEVERE, null, ex);
            }

        }
    }
    // </editor-fold>
}
